
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Collections;


using Swaf;
using Swaf.Container;

namespace Swaf.Versioning
{
	/// <summary>
	/// This versioining dictionary uses a BTree Dictionary as its internal storage.
	/// </summary>
//	[Serializable]
	public class BTreeVersioningDictionary : BaseVersioningDictionary
	{
		/// <summary>
		/// Constructor for the BTreeVersioningDictionary.
		/// </summary>
		public BTreeVersioningDictionary() : base()
		{
			base.m_Source = new BTreeDictionary();
			base.m_Cache = new BTreeDictionary();
		}
		//Because the BTreeDictionary is already threadsafe, we do not need to do anything special.
		#region BaseVersioningDictionary Members

		/// <summary>
		/// Overridden BaseVersioningDictionary readFromCache method.
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		protected override object readFromCache(string key)
		{
			return base.m_Cache[key];
		}
		/// <summary>
		/// Overridden BaseVersioningDictionary writeToCache method.
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		protected override void writeToCache(string key, object value, object extraInfo)
		{
			base.m_Cache[key]=value;
		}
		/// <summary>
		/// Overridden BaseVersioningDictionary readFromSource method.
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		protected override object readFromSource(string key)
		{
			return base.m_Source[key];
		}
		/// <summary>
		/// Overridden BaseVersioningDictionary writeToSource method.
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		protected override void writeToSource(string key, object value, object extraInfo)
		{
			base.m_Source[key]=value;
		}
		#endregion

		#region IDictionary Members
		/// <summary>
		/// Overridden IDictionary Remove method.
		/// </summary>
		/// <param name="key"></param>
		public override void Remove(object key)
		{
			base.Remove(key);
		}

		/// <summary>
		/// Overridden IDictionary Contains method.
		/// </summary>
		/// <param name="key"></param>
		/// <returns></returns>
		public override bool Contains(object key)
		{
			return base.Contains(key);
		}

		/// <summary>
		/// Overridden IDictionary Clear method.
		/// </summary>
		public override void Clear()
		{
			base.Clear();
		}

		/// <summary>
		/// Overridden IDictionary Values property.
		/// </summary>
		public override ICollection Values
		{
			get
			{
				return base.Values;
			}
		}

		/// <summary>
		/// Overridden IDictionary Add method.
		/// </summary>
		/// <param name="key"></param>
		/// <param name="value"></param>
		public override void Add(object key, object value)
		{
			base.Add(key,value);
		}

		/// <summary>
		/// Overridden IDictionary Get property.
		/// </summary>
		public override ICollection Keys
		{
			get
			{
				return base.Keys;
			}
		}
		#endregion
		#region ICollection Members

		/// <summary>
		/// Overridden ICollection Count property.
		/// </summary>
		public override int Count
		{
			get
			{
				return base.Count;
			}
		}

		/// <summary>
		/// Overridden ICollection CopyTo method.
		/// </summary>
		/// <param name="array"></param>
		/// <param name="index"></param>
		public override void CopyTo(Array array, int index)
		{
			base.CopyTo(array, index);
		}


		#endregion
	}
}
